import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import layout from "@views/layout/index.vue";
import login from "@views/login/index.vue";
// 每个路由规则都是一个配置对象RouteRecordRaw 
export const constantRoutes: Array<RouteRecordRaw> = [
    {
        path: "/",
        // 使用name属性为路由取一个名字，也称为命名路由 
        name: "Login",
        // 当前路由规则对应要展示的组件
        component: login,
    },
    {
        path: "/index",
        // 使用name属性为路由取一个名字，也称为命名路由 
        name: "layout",
        // 当前路由规则对应要展示的组件
        // 静态导入的组件 
        component: layout,
        //路由原信息
        //redirect: '/index2',
        // 路由懒加载。第一次进入页面时才会加载对应组件 
        //component: () => import('@/views/Layout/index.vue'), 
        // 路由元信息，也是路由附加信息 
        meta: {
            // 不在菜单中显示
            //hidden: true,
        }, children: [{
            path: "",
            name: "Index",
            // 路由懒加载。第一次进入页面时才会加载对应组件 
            component: () => import('@views/admin/index.vue'),
            // 元数据,在生成菜单时使用 
            meta: {
                title: "首页",
                icon: "iconfont icon-shouye",
                isRoot: true,
                isAffix: true,
            },
        },
        ],
    },
    {
        path: "/userCenter",
        name: "userCenter",
        component: layout,
        meta: { },
        children: [
            {
                path: "",
                name: "UserCenter",
                component: () => import("@/views/user/userCenter.vue"),
                meta: {
                    title: "个人中心",
                },
            }
        ],
    },
    {
        path: "/teacher",
        name: "Teacher",
        component: layout,
        redirect: "/teacher/list",
        meta: {
            title: "讲师管理"
        },
        children: [
            {
                path: "list",
                name: "TeacherList",
                component: () => import("@views/admin/teacher/teacherList.vue"),
                meta: {
                    title: "讲师列表"
                },
            }
        ]
    },
    {
        path: "/subject",
        name: "Subject",
        component: layout,
        redirect: "/subject/list",
        meta: {
            title: "课程管理",
        },
        children: [
            {
                path: "list",
                name: "SubjectList",
                component: () => import("@/views/admin/subject/subjectList.vue"),
                meta: {
                    title: "课程列表",
                },
            }
        ],
    },
    {
        path: "/video",
        name: "Video",
        component: layout,
        redirect: "/video/list",
        meta: {
            title: "视频管理",
        },
        children: [
            {
                path: "list",
                name: "VideoList",
                component: () => import("@/views/admin/video/videoList.vue"),
                meta: {
                    title: "视频列表",
                },
            }
        ],
    },
]
const router = createRouter({
    // Hash Mode 
    history: createWebHashHistory(),
    // routes是路由规则数组 
    routes: constantRoutes,
})
export default router;